tests/sizes.js: Fix byte array unpacking
authorDan Nicholson <nicholson@endlessm.com>
Mon, 8 Jul 2019 21:08:07 +0000 (15:08 -0600)
committerAtomic Bot <atomic-devel@projectatomic.io>
Tue, 23 Jul 2019 12:49:26 +0000 (12:49 +0000)
Recent GJS changed how byte arrays are unpacked with some assumptions
that they are likely strings. Manually use get_child_value() and
get_byte() to ensure the correct value is parsed when checking the
`ostree.sizes` metadata.

The upstream test is currently passing fine with GJS 1.56.2, but at
Endless we (unfortunately) have a downstream change that adds the object
type as an additional byte in the array. This is parsed incorrectly by
`deep_unpack()`. We can carry this patch downstream, but this change
makes the test more robust regardless.

Closes: #1884
Approved by: cgwalters

tests/test-sizes.js

index d923e749ccf14ed57723a6230295f3afaf3a7f84..73b179c58978a9c08ef1aafaf125265234ba40c0 100755 (executable)
@@ -64,10 +64,10 @@ assertEquals(nSizes, 2);
 let expectedUncompressedSizes = [12, 18];
 let foundExpectedUncompressedSizes = 0;
 for (let i = 0; i < nSizes; i++) {
-    let sizeEntry = sizes.get_child_value(i).deep_unpack();
-    assertEquals(sizeEntry.length, 34);
-    let compressedSize = sizeEntry[32];
-    let uncompressedSize = sizeEntry[33];
+    let sizeEntry = sizes.get_child_value(i);
+    assertEquals(sizeEntry.n_children(), 34);
+    let compressedSize = sizeEntry.get_child_value(32).get_byte();
+    let uncompressedSize = sizeEntry.get_child_value(33).get_byte();
     print("compressed = " + compressedSize);
     print("uncompressed = " + uncompressedSize);
     for (let j = 0; j < expectedUncompressedSizes.length; j++) {